package cn.e4j.modular.crm.service.impl;

import cn.e4j.core.dto.Dtos;
import cn.e4j.core.dto.impl.Dto;
import cn.e4j.modular.crm.entity.GwcaT;
import cn.e4j.modular.crm.mapper.Gwcq003Mapper;
import cn.e4j.modular.crm.service.Gwcq003Service;
import cn.e4j.modular.erp.controller.ErpLogic;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Gwcq003ServiceImpl extends ServiceImpl<Gwcq003Mapper, GwcaT> implements Gwcq003Service {
    @Autowired
    private ErpLogic erpLogic;

    @Override
    public List<Dto> getList(Page<Object> page, Dto dto) {
        List<Dto> gwcq003List = this.baseMapper.getList(page,dto);
        for (Dto gwcq003Dto : gwcq003List) {
            Dto erpData;
            try {
                erpData = erpLogic.getERPService("getGwcq003Data", dto);
            } catch (NoSuchMethodException e) {
                throw new RuntimeException("T100 ServiceImplement没有该方法");
            }
            if(erpData != null) {
                gwcq003Dto.putAll(erpData);
            }
        }
        return this.baseMapper.getList(page,dto);
    }
}
